<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <title>SWM - UFASTA</title>
        <link type="text/css" rel="stylesheet" href="/stylesheets/{{ user.theme }}" />
        <link type="text/css" rel="stylesheet" href="/stylesheets/jquery-ui-1.8.9.custom.css" />
        <link type="text/css" rel="stylesheet" href="/stylesheets/jquery-ui-numeric.css" />
		
		<link rel="stylesheet" href="/stylesheets/core.css" type="text/css" />
		
        <script type="text/javascript" src="/js/jquery-1.5.min.js">
        </script>
        <script type="text/javascript" src="/js/jquery.simplemodal-1.4.1.js">
        </script>
        <script type="text/javascript" src="/js/jquery-ui-1.8.9.custom.min.js">
        </script>
        <script type="text/javascript" src="/js/datetimepicker.js">
        </script>
        <script type="text/javascript" src="/js/swm.js">
        </script>
        <script type="text/javascript" src="/js/jquery-ui-numeric.js">
        </script>
        <script type="text/javascript" src="/js/jquery-ui-numeric-min.js">
        </script>
		<script type="text/javascript" src="/js/validate/jquery.validate.js">
        </script>
		<script type="text/javascript" src="/js/validate/localization/messages_es.js">
        </script>
	    <script src="/js/jMonthCalendar.js" type="text/javascript">
	    </script>


	<style type="text/css" media="screen">
		#jMonthCalendar .calendar_deadline { background-color:rgba(255,0,0,0.35);}
	</style>
	
	
    <script type="text/javascript">
        function getCalendar() {
			var options = {
				height: 450,
				width: 680,
				navHeight: 25,
				labelHeight: 25,
				containerId: "#jMonthCalendar",
				onMonthChanging: function(dateIn) {
					return true;
				},
				onEventLinkClick: function(event) { 
					//alert("event link click");
					return true; 
				},
				onEventBlockClick: function(event) { 
					//alert("block clicked");
					return true; 
				},
				onEventBlockOver: function(event) {
					//alert(event.Title + " - " + event.Description);
					return true;
				},
				onEventBlockOut: function(event) {
					return true;
				},
				onDayLinkClick: function(date) { 
					alert(date.toLocaleDateString());
					return true; 
				},
				onDayCellClick: function(date) { 
					return true; 
				}
			};
			
			
			var events = [ 	{% for aTask in task_list %}
			                	{% for aEvent in aTask.calendarList %}
									{{ aEvent }}
								{% endfor %}
							{% endfor %}
			];
			
			//$.jMonthCalendar.Initialize(newoptions, newevents);

			
			$.jMonthCalendar.Initialize(options, events);
			
			$("#Button").click(function() {					
				$.jMonthCalendar.AddEvents(extraEvents);
			});
			
			$("#ChangeMonth").click(function() {
				$.jMonthCalendar.ChangeMonth(new Date(2008, 4, 7));
			});
			
			showDialog("jMonthCalendar");
        };
    </script>
		
    </head>
    <body>
        <div id="top">
            <div id="usr_info">
             <a target="_blank" class="gray_link" href="http://mail.google.com"><b>{{ user.email }}</b></a> | <a onclick='showDialog("conf_admin")' class="gray_link" href="#">Configuración</a> | <a class="gray_link" href="/user_logout">Salir</a> 
            </div>
            <div id="menu">
					<img src="/imgs/logo.png" alt="" />
					<a href='javascript:n()'><img src="/imgs/task_new.png" class="menu_icon" alt="" onclick='showDialog("task_admin_dialog")'  /></a>
					<a href='javascript:n()'><img src="/imgs/cat_new.png" class="menu_icon" alt="" onclick='showDialog("category_creator_dialog")' /></a>
					<a href='javascript:n()'><img src="/imgs/cat_admin.png" class="menu_icon" alt="" onclick='showDialog("category_admin")' /></a>
					<a href='javascript:n()'><img src="/imgs/calendar.png" class="menu_icon" alt="" onclick='getCalendar()' /></a>
					<a href='/print_task?position={{ user.position }}'><img src="/imgs/print.png" class="menu_icon" alt=""/></a>
					<a href='/user_logout'><img src="/imgs/logout.png" class="menu_icon" alt=""/></a>
            </div>
        </div>
        <div id="bkg">
        </div>
        <div id="body">
            <div id="body_bar_contener" class="body_contener">
            	<div id="position_contener" class="task_contener droppable">{{ user.render_position }}</div>
            </div>
			
			{% if draw_category_creater %}
            <div id="category_creater" class="body_contener">
                <form id="form_category_creater" class="submitable" action="/save_category" method="post" accept-charset="utf-8">
                    <div class="task_contener">
						<div class="category_name_contener">
							{{ category_name }}
						</div>
						{% for aField in fields %} 
	                    <div class="task_field_name_contener">
							<label>Nombre del Campo:</label> 
						</div>
						<div class="task_field_value_contener">
							<input class="field_editer category_editer required" maxlength="20" type="text" name="{{ aField.name }}" />
							<label class="task_field_name_contener">Tipo de Dato: </label> 
	                    	<select class="category_editer" name="{{ aField.typeName }}">
	                        	{% for aType in types %}<option value="{{ aType.value }}">{{ aType.name }}</option>
	                        	{% endfor %}
	                    	</select>
							<label class="task_field_name_contener">¿Obligatorio?</label>
							<input type="checkbox" name="{{ aField.name }}_req"/>
						</div>                
						{% endfor %}
					<input type="hidden" value="{{ category_name }}" name="category_name">
					<input type="hidden" value="{{ field_quantity }}" name="field_quantity">
					<div class="task_menu_contener">
						<a onclick='submitForm("form_category_creater")' href="javascript:n()">Guardar Cambios</a>
					</div>
			        <div id="errors_form_category_creater" class="errors_contener">
                		<ul id="errors_form_category_creater" ></ul>
					</div>
					</div>            
				</form>
				
            </div>{% endif %}
            {% if draw_task_creater %}
            <div id="task_creater" class="body_contener">
                <div class="task_contener">
                    <div class="task_name_contener">
					{{ task_to_edit.name }}
					</div>
                    <form id="form_save_task" class="submitable" action="/save_task" method="post" accept-charset="utf-8">
                        <input type="hidden" name="task_key" value="{{ task_to_edit.key }}"/>
						{% for aField in task_to_edit.fields %}
                        <div class="task_field_contenter">
                            <div class="task_field_name_contener">
								<label>
                                	{{ aField.fname }}
                            	</label>
							</div>
							<div class="task_field_value_contener">
                            	{% ifequal aField.ftype "TextTaskField" %}
                            		<textarea name="{{ aField.fkey }}" class="{{aField.fvalidators}} field_editer text_area_editer" rows=1 >{{aField.fvalue}}
                            		</textarea>
                            	{% else %}
                            		{% ifequal aField.ftype "DeadLineTaskField" %}
										<div class="task_deadline_contener">
											<input type="text" name="{{aField.fkey}}" class="{{aField.fvalidators}} field_editer dead_line_date_editer {{aField.ftype}}" value="{{aField.fvalue}}"/>
											<label class="dead_line_label">
                                	       		Mensaje de vencimiento:	
                            	        	</label>
											<input type="text" name="{{aField.fkey}}_m" class="{{aField.fvalidators}} field_editer dead_line_message_editer StringTaskField" value="{{aField.fmessage}}"/>
										</div>									
									{% else %}
										<input type="text" name="{{aField.fkey}}" class="{{aField.fvalidators}} field_editer {{aField.ftype}}" value="{{aField.fvalue}}"/>
									{% endifequal %}
                            	{% endifequal %}
							</div>
                        </div>
						{% endfor %} 
						<div class="task_menu_contener">
							<a onclick='submitForm("form_save_task")' href="#">Guardar Cambios</a>
						</div>
                    </form>
                <div id="errors_form_save_task" class="errors_contener">
                	<ul id="errors_list_form_save_task" ></ul>
				</div>
				</div>
            </div>{% endif %}
            <div id="task_lister" class="body_contener">
                {% for aTask in task_list %}
			    <div id="{{aTask.key}}" class="task_contener droppable draggable {% if aTask.isCompleted %}task_completed_contener{% endif %}">
                    <div class="task_name_contener">
						<div class="task_name_options_contener">
						<a id="toggleler_{{aTask.key}}" class="toggleler" onclick='toggleTaskContent("{{aTask.key}}")' href="javascript:n()">[-]</a>
						<a id="closer_{{aTask.key}}" class="toggleler" onclick='hideTaskContent("{{aTask.key}}")' href="javascript:n()">[x]</a>
						<a href="/?position={{aTask.key}}">{{ aTask.name }}</a>
						</div>
						{% if aTask.hasExpired %}
							<div class="task_expired_message">{{aTask.expMessage}}</div>
						{% endif %}
                    </div>
                    <div id="expander_contener_{{aTask.key}}" class="task_fields_border">
					{% for aField in aTask.fields %}
					<div class="task_field_contener">
                        <div class="task_field_name_contener">
                            {{ aField.fname }}
                        </div>
                        <div class="task_field_value_contener{% ifequal aField.ftype "DeadLineTaskField" %} hola {% if aField.expired %} task_field_value_expired {% endif %} {% endifequal %} ">
                            {{ aField.fvalue }}
                        </div>
                    </div>
                    {% endfor %}
					</div>                    
					<div class="task_menu_contener">
                          <a onclick='showQuestion("ao_completed","{{aTask.key}}")' href="javascript:n()">{% if aTask.isCompleted %} Re-abrir {% else %} Finalizar {% endif %}</a>
						| <a onclick='showQuestion("ao_share","{{aTask.key}}")' href="javascript:n()">Compartir</a>
						| <a href="/update_task?task_key={{aTask.key}}">Modificar</a>
						| <a href="/print_task?task_key={{aTask.key}}">Imprimir</a>
                        | <a onclick='showQuestion("ao_delete","{{aTask.key}}")' href="javascript:n()">Eliminar</a>
						  
						  <div id="ao_completed_{{aTask.key}}" class="task_menu_additional_options question">
						  	¿Estas seguro que quieres {% if aTask.isCompleted %} Re-abrir {% else %} Finalizar {% endif %} esta tarea?
						  	<br>
							<a href="/change_completed_state?task_key={{aTask.key}}">Si</a> | 
						  	<a onclick='hideQuestion("{{aTask.key}}")' href="javascript:n()">No</a>
						  </div>
						  
						  <div id="ao_share_{{aTask.key}}" class="task_menu_additional_options">
						  	<form id="form_share_task_{{aTask.key}}" class="submitable" action="/share_task" method="post" accept-charset="utf-8">
								<input type="hidden" value="{{aTask.key}}" name="task_key" />
								<div class="task_field_name_contener">
									<label>E-mail del usuario destinatario:</label>
								</div>
								<div class="task_field_value_contener sharing_email_contener">
									<input type="text" name="user_email" class="field_editer required email"/>
								</div><br>
								<div id="errors_form_share_task_{{aTask.key}}" class="errors_contener">
            				    </div>
								<a onclick='submitForm("form_share_task_{{aTask.key}}")' class="question" href="javascript:n()">Compartir</a> | 
								<a onclick='hideQuestion("{{aTask.key}}")' class="question" href="javascript:n()">Cancelar</a>
							</form>
							
						  </div>
						  
						  <div id="ao_delete_{{aTask.key}}" class="task_menu_additional_options question">¿Estas seguro que quieres eliminar esta tarea?
						  	<br>
							<a href="/delete_task?task_key={{aTask.key}}">Si</a> | 
						  	<a onclick='hideQuestion("{{aTask.key}}")' href="javascript:n()">No</a>	
						  </div>	
                    </div>
					
                </div>
                {% endfor %}
				<center>
					<div id="credits">
						2011 - Ignacio Belderrain - Universidad Fasta Mar del Plata
					</div>
					<img src="http://code.google.com/appengine/images/appengine-noborder-120x30.gif" alt="Powered by Google App Engine" />
				</center>
            </div>
        </div>
		
		<div id="category_admin" class="swm_dialog">
			<div class="category_name_contener category_admin_title">Administrador de Categorías</div>
			{% for aCategory in category_list %}
				<label class="task_field_name_contener">{{ aCategory.name }}</label>   
				<a class="category_field_value_contener" href="/delete_category?category_key={{ aCategory.key }}">eliminar</a><br>
            {% endfor %}
		</div>
		
		<div id="conf_admin" class="swm_dialog">
			<form id="form_conf" action="/change_conf" class="submitable">
				<div class="category_name_contener category_admin_title">Elige un Tema</div>
				<select name="theme" class="task_contener">
					<option value="default.css">Default</option>
					<option value="clear.css">Clear</option>
					<option value="girls.css">Girls</option>
				</select>
				<div class="task_menu_contener">
                	<a onclick="submitForm('form_conf')" href="javascript:n()" >Guardar</a>
				</div>
			</form>
		</div>	
		
		<div id="task_admin_dialog" class="swm_dialog">
			<form id="form_new_task" class="form_margin submitable" action="/new_task?position={{ user.position }}" method="post" accept-charset="utf-8">
                <div class="category_name_contener category_admin_title">Crear Nueva Tarea</div>
				<label class="task_field_name_contener">Nombre: </label>
				<div class="task_field_value_contener">
					<input class="required field_editer" type="text" name="task_name"/>
                </div>
				<label class="task_field_name_contener">Categoría: </label>
				<select class="input_margin required" name="task_category">
                    {% for aCategory in category_list %}
					<option value="{{ aCategory.key }}">{{ aCategory.name }}</option>
                    {% endfor %}
                </select>
				<div class="task_menu_contener">
                	<a onclick="submitForm('form_new_task')" href="javascript:n()" >Crear</a>
				</div>
				<div id="errors_form_new_task" class="errors_contener">
            	</div>
            </form>
		</div>
		
		<div id="category_creator_dialog" class="swm_dialog">
            <div class="category_name_contener category_admin_title">Crear nueva categoría</div> 
            <form id="new_category_form" class="submitable" action='/new_category' method="post" accept-charset="utf-8" target="_top">
                    <label class="task_field_name_contener">Nombre:</label>
					<div class="task_field_value_contener">
					<input class="field_editer required" type="text" name="category_name" /><br>
					</div>
					<label class="task_field_name_contener">Campos:</label>
					<div class="task_field_value_contener">
					<input class="IntegerCatField required" type="text" name="fields_quantity"/><br>
					</div>
					<div class="task_menu_contener">
						<a onclick="submitForm('new_category_form')" href="javascript:n()" >Crear</a>
					</div>
            </form>
			<div id="errors_new_category_form" class="errors_contener">
            </div>
        </div>
		
		<div id="jMonthCalendar" class="swm_dialog"></div>
		
		
		
    </body>
</html>
